package com.bocai.yuweiwangluo.activity;


import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import com.bocai.yuweiwangluo.R;
import com.bocai.yuweiwangluo.base.BaseActivity;
import com.bocai.yuweiwangluo.utils.SharePrefencesUtil;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

/**
 * 设置
 */
public class SettingActivity extends BaseActivity implements View.OnClickListener{

    @ViewInject(R.id.ll_setting_aboutus)
    LinearLayout llAbout;
    @ViewInject(R.id.ll_setting_setting_bindingphone)
    LinearLayout llSettingBindingPhone;
    @ViewInject(R.id.ll_setting_settingpsd)
    LinearLayout llSettingPsd;
    @ViewInject(R.id.btn_exit)
    Button btn_exit;
    @Override
    protected int contentView() {
        return R.layout.activity_setting;
    }

    @Override
    protected void setData() {
        ViewUtils.inject(this);
        initToolbar("设置");
        initEvent();

    }

    @Override
    protected void initEvent() {
        super.initEvent();
        llAbout.setOnClickListener(this);
        llSettingBindingPhone.setOnClickListener(this);
        llSettingPsd.setOnClickListener(this);
        btn_exit.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ll_setting_settingpsd:
                //设置新密码
                startActivity(new Intent(this,SetNewPsdActivity.class));
                break;
            case R.id.ll_setting_setting_bindingphone:
                //绑定新手机号
                startActivity(new Intent(this,BindingNewPhoneActivity.class));
                break;
            case R.id.ll_setting_aboutus:
                //跳转关于我们界面
                startActivity(new Intent(this,AboutUsActivity_new.class));
                break;
            case R.id.btn_exit:
                SharedPreferences sharedPreferences=getSharedPreferences("user",MODE_PRIVATE);
                SharedPreferences.Editor editor=sharedPreferences.edit();
                if(!"true".equals(SharePrefencesUtil.getIsRememberPsd(this)))
                {
                    editor.putString("password","");
                }
                editor.putString("user_id","");
                editor.putString("nickname","");
                editor.putString("flag","");
                editor.putString("state", "");
                editor.putString("number", "");
                editor.putString("photo","");
                editor.commit();
                startActivity(new Intent(this,LoginActivity.class));
                break;

        }
    }
}
